package com.xzx.shop_front_api.service.impl;

import com.xzx.shop_front_api.entity.Goods;
import com.xzx.shop_front_api.entity.News;
import com.xzx.shop_front_api.mapper.GoodsMapper;
import com.xzx.shop_front_api.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
    public class GoodsServiceImpl implements GoodsService {
        @Autowired
        private GoodsMapper goodsMapper;

        @Override
        public int addGoods(Goods goods) {
            goods.setSalesNumber(0);
            return goodsMapper.insert(goods);
        }

    @Override
    public Goods getGoodsById(Long id) {
        return goodsMapper.selectById(id);
    }

    @Override
    public int deleteGoodById(Long id) {
        return goodsMapper.deleteById(id);
    }

    @Override
    public List<Goods> getAllGoods() {
        return goodsMapper.selectAll();
    }

    @Override
    public int deleteGoodsById(Long id) {
        return goodsMapper.deleteById(id);
    }

}

